import { Circle as CircleStyle, Fill, Stroke, Style, Text } from 'ol/style';

export const getStyle = (type, select, text, name) => {
    let style
    let changeColor
    switch (type) {
        case 'xm_shoppoint':
            changeColor = select ? 'rgba(85, 164, 238, 1)' : 'rgba(249, 77, 62, 0.4)'
            style = [
                new Style({
                    image: new CircleStyle({
                        radius: 20,
                        fill: new Fill({
                            color: changeColor,
                        }),
                    }),
                }),
                new Style({
                    image: new CircleStyle({
                        radius: 15,
                        fill: new Fill({
                            color: 'rgba(249, 77, 62, 1)',
                        }),
                    }),
                    text: new Text({
                        font: '15px sans-serif',
                        text: text.toString(),
                        fill: new Fill({
                            color: '#fff'
                        })
                    })
                })
            ]
            break;
        case 'xm_lrdl':
            changeColor = select ? 'rgba(85, 164, 238, 1)' : 'rgba(179, 162, 115, 1)'
            style = new Style({
                // 面样式
                fill: new Fill({
                    color: 'rgba(255, 185, 0, 0.2)',
                }),
                // 线样式
                stroke: new Stroke({
                    color: changeColor,
                    width: 4
                }),
                // 点样式
                image: new CircleStyle({
                    radius: 7,
                    fill: new Fill({
                        color: '#0883d8',
                    }),
                }),
            })
            break;
        case 'xm_building':
            changeColor = select ? 'rgba(85, 164, 238, 1)' : 'rgba(204, 0, 255, 0.6)'
            style = new Style({
                // 面样式
                fill: new Fill({
                    color: changeColor,
                }),
                // 线样式
                stroke: new Stroke({
                    color: changeColor,
                }),
                // 点样式
                image: new CircleStyle({
                    radius: 7,
                    fill: new Fill({
                        color: '#0883d8',
                    }),
                }),
            })
            break;
        case 'search':
            changeColor = select ? 'rgba(88, 97, 116, 0.3)' : 'rgba(85, 164, 238, 1)'
            if (name == 'draw') {
                style = new Style({
                    fill: new Fill({
                        color: 'rgba(255, 255, 255, 0.5)',
                    }),
                    stroke: new Stroke({
                        color: '#ffcc33',
                        width: 2,
                    }),
                    image: new CircleStyle({
                        radius: 7,
                        fill: new Fill({
                            color: '#ffcc33',
                        }),
                    }),
                })
            } else {
                style = new Style({
                    // 面样式
                    fill: new Fill({
                        color: changeColor,
                    }),
                    // 线样式
                    stroke: new Stroke({
                        color: changeColor,
                        width: 4,
                    }),
                    // 点样式
                    image: new CircleStyle({
                        radius: 7,
                        fill: new Fill({
                            color: 'rgba(33, 64, 119, 0.8)'
                        }),
                        stroke: new Stroke({
                            color: changeColor,
                            width: 2
                        }),
                    }),
                })
            }
            break;
        case 'add':
            style = new Style({
                fill: new Fill({
                    color: 'rgba(255, 255, 255, 0.5)',
                }),
                stroke: new Stroke({
                    color: '#ffcc33',
                    width: 2,
                }),
                image: new CircleStyle({
                    radius: 7,
                    fill: new Fill({
                        color: '#ffcc33',
                    }),
                }),
            })
            break;
    }
    return style
}